/********************************************************************************
*                 Copyright (C) 2011 - Las Venturas Playground                  *
*                      http://iv-mp.nl | http://lvp-iv.com                      *
*                                                                               *
*    This program is free software: you can redistribute it and/or modify       *
*    it under the terms of the GNU General Public License as published by       *
*    the Free Software Foundation, either version 3 of the License, or          *
*    (at your option) any later version.                                        *
*                                                                               *
*    This program is distributed in the hope that it will be useful,            *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of             *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
*    GNU General Public License for more details.                               *
*                                                                               *
*    You should have received a copy of the GNU General Public License          *
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
*                                                                               *
*********************************************************************************
*                                                                               *
*  Las Venturas Playground - clientscript: help.nut                             *
*                                                                               *
*  This file will hold the LVP:IV Help system.                                  *
*                                                                               *
********************************************************************************/

//Definitions
local screen = guiGetScreenSize();
local showhelp = false;
local font = GUIFont("tahoma", 12);
local boldfont = GUIFont("tahoma-bold", 14);
local headerfont = GUIFont("pricedown", 32);

// Create the Help system layout
local windowHelp = GUIWindow();
    windowHelp.setVisible(false);
    windowHelp.setSize(800.0, 600.0, false);
    windowHelp.setPosition(screen[0]/2-400, screen[1]/2-300.0, false);
    windowHelp.setText("LVP:IV Help");

local btnPrevious = GUIButton();
    btnPrevious.setVisible(false);
    btnPrevious.setPosition(screen[0]/2-400+25, screen[1]/2+255.0, false);
    btnPrevious.setSize(80.0, 20.0, false);
    btnPrevious.setText("<- Previous");

local btnClose = GUIButton();
    btnClose.setVisible(false);
    btnClose.setPosition(screen[0]/2-40, screen[1]/2+255.0, false);
    btnClose.setSize(80.0, 20.0, false);
    btnClose.setText("close");
    
local btnNext = GUIButton();
    btnNext.setVisible(false);
    btnNext.setPosition(screen[0]/2+295, screen[1]/2+255.0, false);
    btnNext.setSize(80.0, 20.0, false);
    btnNext.setText("Next ->");

local editboxSearch = GUIEditBox();
    editboxSearch.setVisible(false);
    editboxSearch.setPosition(screen[0]/2+225, screen[1]/2-287.5, false);
    editboxSearch.setSize(150.0, 20.0, false);     
    editboxSearch.setText("Search...");
    
function onFrameRender()
{
    if(showhelp == true)
    {
        // Draw titlebar
        guiDrawRectangle(screen[0]/2-400, screen[1]/2-300, 800.0, 50.0, 0x50505080, false);     
        headerfont.drawText(screen[0]/2-80,screen[1]/2-300.0, "LVP:IV Help", false);
        
        // Draw main window
        guiDrawRectangle(screen[0]/2-400, screen[1]/2-250.0, 800.0, 550.0, 0x00000080, false);
        font.drawText(screen[0]/2-400+25,screen[1]/2-250.0, "In this help system we try to provide you some basic information.", false);
        boldfont.drawText(screen[0]/2-400+25,screen[1]/2-225.0, "[60606000]Table of contents", false);
        guiDrawRectangle(screen[0]/2-375, screen[1]/2-202.5, 750.0, 2.0, 0xFF000080, false);
        font.drawText(screen[0]/2-400+25,screen[1]/2-200.0, "- Rules\n- Registering\n- Commands\n", false);
    }
}

addEvent("frameRender", onFrameRender);

function onButtonClick(btnName, bState)
{
    if(btnName == btnPrevious.getName())
    {

    }

    if(btnName == btnNext.getName())
    {

    }

    if(btnName == btnClose.getName())
    {
        toggleChatWindow(true);
        guiToggleCursor(false);        
        showhelp = false;
        btnPrevious.setVisible(false);
        btnClose.setVisible(false);
        btnNext.setVisible(false);
        editboxSearch.setVisible(false);

    }      
}
addEvent("buttonClick", onButtonClick);

function onPlayerCommand(command)
{
    if(command == "/help2")
    {
            toggleChatWindow(false);
            guiToggleCursor(true);
            showhelp = true;   
            btnPrevious.setVisible(true);
            btnClose.setVisible(true);
            btnNext.setVisible(true);
            editboxSearch.setVisible(true);
    }
}
addEvent("playerCommand", onPlayerCommand);